<template>
  <div>
    子组件:
    <span>{{virtualWalletId}}</span>
  </div>
</template>
<script>
export default {
  // 接受父组件传递过来的参数
  props: ["inputName"],
  data() {
    return {
      virtualWalletId: ""
    };
  },
  computed: {
    user() {
      return this.$store.state.userMsg;
    }
  },
  created() {
    console.log(this.inputName, 9999);
    this.enterLogin();
  },
//   监听下父组件传过来的参数
  watch: {
    inputName() {
      this.enterLogin();
    }
  },
  mounted() {},
  methods: {
    enterLogin() {
      let that = this;
      that.$axios
        .get(that.address.userVirtualWallet, {
          params: {
            token: that.user.token,
            virtuaWalletName: this.inputName
          }
        })
        .then(res => {
          if (res.data.code == 200) {
            that.virtualWalletId = res.data.data[0].virtualWalletId;
            console.log(that.virtualWalletId, 666);
          } else {
          }
        });
    }
  }
};
</script>
<style lang="less" scoped>
</style>
